// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   milStd.java

package qcs.config.publics;

import include.nseer_db.nseer_db_backup1;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import uk.ltd.getahead.dwr.WebContext;
import uk.ltd.getahead.dwr.WebContextFactory;

public class milStd
{

	WebContext ctx;
	HttpServletRequest request;
	HttpSession session;
	ServletContext application;
	nseer_db_backup1 qcs_db;

	public milStd()
	{
		ctx = WebContextFactory.get();
		request = ctx.getHttpServletRequest();
		session = request.getSession();
		application = session.getServletContext();
		qcs_db = new nseer_db_backup1(application);
	}

	public List getTypeGroup(String group_id)
	{
		List list = new ArrayList();
		try
		{
			if (qcs_db.conn((String)session.getAttribute("unit_db_name")))
			{
				String sql = (new StringBuilder("select type_id,type_name,sample_amount from qcs_config_mil_std where group_id='")).append(group_id).append("'").toString();
				String array[];
				for (ResultSet rs = qcs_db.executeQuery(sql); rs.next(); list.add(array))
				{
					array = new String[3];
					array[0] = rs.getString("type_id");
					array[1] = rs.getString("type_name");
					array[2] = rs.getString("sample_amount");
				}

				qcs_db.commit();
				qcs_db.close();
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return list;
	}

	public List getValue(String type_id, String group_id)
	{
		List list1 = new ArrayList();
		List list2 = new ArrayList();
		try
		{
			String group_column = "";
			if (qcs_db.conn((String)session.getAttribute("unit_db_name")))
			{
				String sql = "select type_id from qcs_config_public_char where kind='AQL'";
				ResultSet rs;
				for (rs = qcs_db.executeQuery(sql); rs.next(); list1.add(rs.getString("type_id")));
				sql = (new StringBuilder("select * from qcs_config_mil_std where group_id='")).append(group_id).append("' and type_id='").append(type_id).append("'").toString();
				rs = qcs_db.executeQuery(sql);
				if (rs.next())
				{
					for (int i = 0; i < list1.size(); i++)
					{
						String array[] = new String[3];
						array[0] = (String)list1.get(i);
						array[1] = rs.getString((new StringBuilder("aql")).append(((String)list1.get(i)).replace(".", "p")).append("_ac").toString());
						array[2] = rs.getString((new StringBuilder("aql")).append(((String)list1.get(i)).replace(".", "p")).append("_re").toString());
						list2.add(array);
					}

				}
				qcs_db.commit();
				qcs_db.close();
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return list2;
	}
}
